package com.jiazhong.x.y.z.servletA;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Auther:shuXin
 */
@WebServlet("/servletA")
public class ServletA extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //System.out.println(111);
        //重定向地址至 src/main/webapp/a/b/c/test.html 使用的是相对路径获得地址的值
        //resp.sendRedirect("../../../a/b/c/test.html");
        //使用绝对路径获得地址的值 第一种防止直接拿项目的上下文的路径
        //resp.sendRedirect("/servlet_test_war/a/b/c/test.html");
        //第二种方式
        //resp.sendRedirect(req.getContextPath() + "/a/b/c/test.html");
        resp.sendRedirect("/a/b/c/test.html");
    }
}
